/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ez2find.manager;

import com.ez2find.model.Forum;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author org.@le
 */
@Stateless
public class ForumManagerBean implements ForumManagerLocal {
    
    
    @PersistenceContext
    private EntityManager em;
    
    public void create(Forum forum)throws Exception {
        em.persist(forum);
    }
 
    public void update(Forum forum)throws Exception {
        em.merge(forum);
    }
    
    public void delete(Forum forum)throws Exception {
        forum=em.merge(forum);
        em.remove(forum);
    }
    
    public Forum find(long id){
        return em.find(Forum.class,id);
    }
    
    public List<Forum> listAll(){
        return em.createQuery("select c from Forum c").getResultList();

    }
 
}
